      SUBROUTINE SETAIT(SYMHLD,PLTPRM)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C  --------------- SETAIT / AITLOC / PRTAIT ---------------------------
C
C  THIS ROUTINE AND ENTRY POINTS ARE USED TO PRODUCE PRINTER PLOTS
C  OF ANGLE QUANTITIES( EX- RACN/DECL, EL/AZ,...). THE PLOT IS 
C  ALWAYS 180x360 DEGREES ON AN OVAL-SHAPED AITOFF GRID. THIS ROUTINE
C  PERFORMS THE SAME SERVICES FOR THE AITOFF GRID THAT SETGRD DOES FOR
C  THE RECTANGULAR GRID.
C 
C  USAGE----  1) CALL SETAIT ONCE TO INTIALIZE SYMHLD AND INTERNAL
C                VARIABLES.
C             2) CALL AITLOC MANY TIMES TO PLACE ANGLE PAIRS ON THE
C                GRID. ONE CALL FOR EACH PAIR PLACED.
C             3) CALL PRTAIT TO PRINT THE GRID.
C
C
C
C  ************************** SETAIT **********************************
C
C  THIS ROUTINE SETS UP AN OVAL-SHAPED GRID FOR SUBSEQUENT USE IN
C  CREATING PRINTER PLOTS OF QUANTITIES EXPRESSED IN
C  LAT/LONG, DECL/RACN, EL/AZ,.....
C
C  THE ARRAY IS RETURNED TO THE CALLER READY TO HAVE OTHER
C  ELEMENTS FILLED SHOWING THE LOCATION ON THE GRID OF THE
C  QUANTITIES PLOTTED.
C
C  ***** NOTE *****     SEE ANGPLT FOR CALLING SEQUENCE DESCRIPTION.
C
C//////////////////////////////////////////////////////////////////////
C
C     STANDARD ARRAYS FOR PETRUZZO'S PRINTER PLOT ROUTINES FOR ANGLES.
C
      LOGICAL*1 SYMHLD(61,121)
      REAL*4 PLTPRM(19)
      INTEGER BOTTOM,RIGHT
      REAL*8 XSEG,YSEG,WEST,SHIFT,DX,DY
C
C/////////////////////////////////////////////////////////////////////
C
C*********************************************************
C
C   CODED BY CHARLIE PETRUZZO   4/81.
C
C   MODIFIED....
C          CJP  6/80 COMMENT CHANGES. NO CODE CHANGED.
C
C*********************************************************
C
      LOGICAL*1 SYMBOL
      LOGICAL*1 VERT/'I'/,HORIZ/'-'/
      REAL*4 TEMP4(2)
      REAL*8 TEMP8
      EQUIVALENCE (TEMP4(1),TEMP8)
C
      REAL*8 HALFPI/ 1.570796326794897D0 /
      REAL*8 PI/ 3.141592653589793D0 /
      REAL*8 TWOPI/ 6.283185307179586D0 /
      REAL*8 DEGRAD/ 57.29577951308232D0 /
      REAL*4 R4IGRD
      EQUIVALENCE (R4IGRD,IGRID)
C
C     SOME PLTPRM ENTRIES ARE NEEDED BY SETAIT CODE. 
      TEMP4(1)=PLTPRM(1)
      TEMP4(2)=PLTPRM(2)
      XSEG=TEMP8
      TEMP4(1)=PLTPRM(3)
      TEMP4(2)=PLTPRM(4)
      YSEG=TEMP8
      TEMP4(1)=PLTPRM(5)
      TEMP4(2)=PLTPRM(6)
      WEST=TEMP8
      R4IGRD=PLTPRM(17)
C
C     SET UP AN OUTSIDE RECTANGULAR BORDER. NO INTERNAL GRID LINES YET.
      R4IGRD=PLTPRM(17)
      ITEMP=IGRID
      IGRID=0
      PLTPRM(17)=R4IGRD
      CALL SETGRD(SYMHLD,PLTPRM)
      IGRID=ITEMP
      PLTPRM(17)=R4IGRD
C
C     SET UP DLONG SO THAT AITOFF ROUTINE WILL TREAT THE
C     LONGITUDES AS THOUGH THE WEST BORDER IS -PI.
      DLONG=PI+WEST
C
C     DRAW THE GRID LINES.
      IF(IGRID.EQ.0) GO TO 325
C
C
C     DRAW THE LATITUDE LINES.
      NLATS=JIDNNT(PI/YSEG)-1
      IF(NLATS.LE.0) GO TO 225
      DO 120 ILAT=1,NLATS
      XLAT=HALFPI-ILAT*YSEG
      DO 120 ILONG=3,363,3
      XLONG=WEST+(ILONG-3)/DEGRAD
      CALL AITOFF(XLAT,XLONG-DLONG,ALAT,ALONG)
      CALL LOCGRD(ALAT,ALONG+DLONG,SYMHLD,PLTPRM,HORIZ)
  120 CONTINUE
C
  225 CONTINUE
C     DRAW THE LONGITUDE LINES.
      NLONGS=JIDNNT(TWOPI/XSEG)-1
      IF(NLONGS.LE.0) GO TO 325
      DO 320 ILONG=1,NLONGS
      XLONG=WEST+ILONG*XSEG
      DO 320 ILAT=3,183,3
      XLAT=HALFPI-(ILAT-3)/DEGRAD
      CALL AITOFF(XLAT,XLONG-DLONG,ALAT,ALONG)
      CALL LOCGRD(ALAT,ALONG+DLONG,SYMHLD,PLTPRM,VERT)
  320 CONTINUE
C
  325 CONTINUE
C
C     NOW DRAW THE LEFT AND RIGHT BORDERS. THIS MAKES THE OVAL.
C     THE LONGITUDES OF THE LEFT AND RIGHT BORDERS ARE THE
C     SAME. USE W1 AND W2 TO FORCE LOCAIT TO PUT SYMBOLS
C     IN BOTH POSITIONS.
      W1=WEST+0.5D0/DEGRAD
      W2=WEST+TWOPI-0.5D0/DEGRAD
      DO 35 ILAT=1,181
      XLAT=HALFPI-(ILAT-1)/DEGRAD
      CALL AITOFF(XLAT,W1-DLONG,ALAT,ALONG)
      CALL LOCGRD(ALAT,ALONG+DLONG,SYMHLD,PLTPRM,VERT)
      CALL AITOFF(XLAT,W2-DLONG,ALAT,ALONG)
      CALL LOCGRD(ALAT,ALONG+DLONG,SYMHLD,PLTPRM,VERT)
   35 CONTINUE
C
C
      RETURN
C
C
C  ************************** AITLOC ********************************
C
      ENTRY AITLOC(ANG1,ANG2,SYMHLD,PLTPRM,SYMBOL)
C
C     THIS CODE TELLS THE CALLER WHERE AN ANGLE PAIR ANG1,ANG2 IS 
C     LOCATED IN SYMHLD. SETAIT MUST BE CALLED BEFORE CALLING AITLOC.
C
C  SEE ANGPL2(ENTRY IN ANGPLT) FOR CALLING SEQUENCE DESCRIPTION.
C
C
C     SET UP DLONG SO THAT AITOFF ROUTINE WILL TREAT THE
C     LONGITUDES AS THOUGH THE WEST BORDER IS -PI.
      TEMP4(1)=PLTPRM(5)
      TEMP4(2)=PLTPRM(6)
      WEST=TEMP8
      DLONG=PI+WEST
      CALL AITOFF(ANG1,ANG2-DLONG,ALAT,ALONG)
      CALL LOCGRD(ALAT,ALONG+DLONG,SYMHLD,PLTPRM,SYMBOL)
C
      RETURN
C
C
C  *************************** PRTAIT ******************************
C
      ENTRY PRTAIT(SYMHLD,PLTPRM,IPRINT)
C
C     THIS CODE PRINTS THE GRID. 
C
C  SEE ANGPL3(ENTRY IN ANGPLT) FOR CALLING SEQUENCE DESCRIPTION.
C
      CALL PRTGRD(SYMHLD,PLTPRM,IPRINT)
C
      RETURN
      END
